package ma.jee.portailReservation.service.announce.Impl;

import ma.jee.portailReservation.persistence.announce.ITravelDAO;
import ma.jee.portailReservation.persistence.announce.Travel;
import ma.jee.portailReservation.service.announce.DisplayTravel;
import ma.jee.portailReservation.service.announce.IDisplayTravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 02/01/12
 * Time: 23:50
 * To change this template use File | Settings | File Templates.
 */
@Service("defaultDisplayTravelService")
public class DefaultDisplayTravelService implements IDisplayTravelService {

    @Autowired
	@Qualifier("hibernateTravelDAO")
	private ITravelDAO travelDAO;

    @Override
    @Transactional(readOnly=true)
    public List<DisplayTravel> getAllDisplayTravels() {

        List<DisplayTravel> result = new ArrayList<DisplayTravel>();

        for(Travel travel : travelDAO.findAll()) {
                  result.add(new DisplayTravel(travel));
        }

        return result;
    }
}
